<header id="topbar" class="affix" style="top:60px;">
    <div class="topbar-left">
        <ol class="breadcrumb">
            <li class="crumb-active">
                <a href="#op/withdraw_control/">提现风控审核</a>
            </li>
        </ol>
    </div>
    <div class="topbar-right">
        <div class="ml15 ib va-m" id="toggle_sidemenu_r">
            <a href="#" class="pl5"> <i class="fa fa-sign-in fs22 text-primary"></i>
            </a>
        </div>
    </div>
</header>


<section id="content" class="animated fadeIn">
    <% if(items.length > 0){ %>
    <div class="panel overflow">
        <table class="table table-striped fs13" id="main-list">
            <thead>
                <tr class="bg-light">
                    <th>提现单号</th>
                    <th>用户ID</th>
                    <th class="sortable" data-field="price">提现金额</th>
                    <th data-field="real_price">到账金额</th>
                    <th>提现方式</th>
                    <th>提现通道</th>
                    <th>审核状态</th>
                    <th>提现状态</th>
                    <th>风控状态</th>
                    <th>系统审核时间</th>
                    <th>审核完成时间</th>
                    <th class="sortable" data-field="updated_at">最后更新时间</th>
                    <th>审核人员</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody class="admin-form">
                <% _.each(items, function(item){
                    var risk_info = item.withdraw_info.auto_risk || '';
                    if (item.withdraw_info.auto_trans_info) {
                        var trans_info = item.withdraw_info.auto_trans_info;
                        var exchange_chn = trans_info.payer_no;
                        if (exchange_chn == 'group_new_withdraw') {
                            exchange_chn = '万豪下分';
                        } else {
                            exchange_chn = '官方下分';
                        }
                    } else {
                        var exchange_chn = '-';
                    }
                    var check_status = WITHDRAW_CHECK_STATUS[item.check_status];
                    if (item.check_status == 0) {
                        if (item.status == 1) {
                            check_status = '等待系统审核';
                        } else {
                            check_status = '系统审核通过';
                        }
                    }
                    if(risk_info) risk_info = '(' + risk_info.length + '条)' + risk_info[0]
                    var incheck_time = item.withdraw_info.incheck_time || item.created_at;
                    var check_time = '-';
                    var admin_id = '-';
                    var admin = '-';
                    if(item.withdraw_info.manual_forbidden_trans_info){
                        var check_time = item.withdraw_info.manual_forbidden_trans_info.check_date || '-';
                        var admin_id = item.withdraw_info.manual_forbidden_trans_info.admin_id;
                    }else if(item.withdraw_info.manual_check_info){
                        var check_time = item.withdraw_info.manual_check_info.check_date || '-';
                        var admin_id = item.withdraw_info.manual_check_info.admin_id;
                    }
                    if(admin_id) admin = user_dict[admin_id];
                %>
                    <tr data-uid="<%= item.uid %>" data-id="<%= item.id %>">
                        <td><a class="modify-item"><%= item.id %></a></td>
                        <td><a href="#stats/account/?id=<%= item.user_id %>"><%= item.is_virtual ? '*' : '' %><%= item.user_id %></a></td>
                        <td><%= item.price %></td>
                        <td><%= item.real_price || '-'%></td>
                        <td><%= WITHDRAW_TYPE[item.target_type] %></td>
                        <td><%= exchange_chn %></td>
                        <td><%= check_status %></td>
                        <td><%= WITHDRAW_STATUS[item.status] %></td>
                        <td><%= risk_info %></td>
                        <td><%= incheck_time %></td>
                        <td><%= check_time %></td>
                        <td><%= item.updated_at %></td>
                        <td><%= admin %></td>
                        <td>
                                <a class="glyphicons glyphicons-pencil modify-item" href="javascript:;"></a>
                        </td>
                    </tr>
                <%
                }) %>
            </tbody>
        </table>
    </div>
    <div><div class="pull-left" id="page-tips"></div><div id="paginator"></div></div>
    <% }else{ %>
    <h4 class="text-muted">无数据</h4>
    <% } %>
</section>

<!-- Panel popup -->
<div id="editWithdrawPanel" class="popup-basic popup-lg bg-none mfp-with-anim mfp-hide">
    <div class="panel">
        <div class="panel-heading">
            <span class="panel-icon"><i class="fa fa-pencil"></i></span>
            <span class="panel-title">提现详情</span>
        </div>
        <div class="panel-body">
            <form id="behavior-form" class="form-horizontal" role="form">
            <div class="form-group">
                <label for="detailId" class="col-md-3 control-label">提现单号：</label>
                <div class="col-md-9">
                    <p class="form-control-static text-muted" id="detailId">
                    </p>
                </div>
            </div>
            <div class="form-group">
                <label for="detailUserId" class="col-md-3 control-label">用户编号：</label>
                <div class="col-md-9">
                    <p class="form-control-static text-muted" id="detailUserId">
                    </p>
                </div>
            </div>
            <div class="form-group">
                <label for="detailCashPrice" class="col-md-3 control-label">提现金额：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-muted" id="detailCashPrice">
                  </p>
                </div>
            </div>
            <div class="form-group">
                <label for="detailCalCashPrice" class="col-md-3 control-label">需转账金额：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-muted" id="detailCalCashPrice">
                  </p>
                </div>
            </div>
            <div class="form-group">
                <label for="detailType" class="col-md-3 control-label">提现方式：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-muted" id="detailType">
                  </p>
                </div>
            </div>
            <div class="form-group">
                <label for="detailInfo" class="col-md-3 control-label">提现信息：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-muted" id="detailInfo">

                  </p>
                </div>
            </div>

            <div class="form-group">
                <label for="otherInfo" class="col-md-3 control-label">交易信息：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-muted" id="otherInfo">
                  </p>
                </div>
            </div>
            <div class="form-group">
                <label for="detailCreatedAt" class="col-md-3 control-label">提现申请时间：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-muted" id="detailCreatedAt">
                  </p>
                </div>
            </div>
            <div class="form-group">
                <label for="riskInfo" class="col-md-3 control-label">风控信息：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-danger" id="riskInfo">
                  </p>
                </div>
            </div>
            <div class="form-group">
                <label for="operateInfo" class="col-md-3 control-label">操作信息：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-danger" id="operateInfo">

                  </p>
                </div>
            </div>
            <div class="form-group">
                <label for="detailStatus" class="col-md-3 control-label">提现状态：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-muted" id="detailStatus">
                  </p>
                </div>
            </div>
            </form>
        </div>
        <div class="panel-footer text-right">
            <button class="btn btn-primary" type="button" id="checkWithdraw">审核通过</button>
            <button class="btn btn-primary" type="button" id="uncheckWithdraw">审核拒绝</button>
            <button class="btn btn-primary" type="button" id="submitWithdraw">自动提现</button>
            <button class="btn btn-primary" type="button" id="finishWithdraw">完成提现</button>
            <button class="btn btn-primary" type="button" id="forbiddenWithdraw">禁止提现</button>
            <button class="btn btn-primary" type="button" id="backWithdraw">返款</button>
            <button class="btn btn-primary" type="button" id="submitClose">关闭</button>
        </div>
    </div>
</div>

<!-- Start: Right Sidebar -->
<aside id="sidebar_right" class="nano" style="top: 110px;">
    <div class="p20 admin-form">
        <h4 class="mt5 text-muted fw500">过滤条件：</h4>
        <hr class="short">
        <div class="section mb15">
            <label class="field prepend-icon">
                <input title="用户ID" type="text" id="searchUid" class="gui-input" data-field="user_id" placeholder="用户ID" value="<%= searched.user_id %>">
                <input title="ID" type="text" id="searchId" class="gui-input" data-field="id" placeholder="订单ID" value="<%= searched.id %>">
                <label class="field-icon"><i class="fa fa-tag"></i>
                </label>
            </label>
        </div>

        <% var tf = searched.time_field || 'created_at',
            title = '申请时间(点击切换)';
            if(tf == 'updated_at')title = '提现时间(点击切换)';
            console.log(tf)
        %>
        <h6 class="fw400" id="switchSearchTime" style="cursor: pointer"><%= title %></h6>
        <div class="section row" id="searchCreatedAt" <%= tf == 'created_at' ? '' : 'hidden' %>>
            <div class="col-md-6">
                <input type="text" class="gui-input datetime-input" data-field="created_at.$gte" data-useless="" placeholder=">=" value="<%= searched.created_at ? searched.created_at.$gte : '' %>">
            </div>
            <div class="col-md-6">
                <input type="text" class="gui-input datetime-input" data-field="created_at.$lte" data-useless="" placeholder="<=" value="<%= searched.created_at ? searched.created_at.$lte : '' %>">
            </div>
        </div>
        <div class="section row" id="searchUpdatedAt" <%= tf == 'updated_at' ? '' : 'hidden' %>>
            <div class="col-md-6">
                <input type="text" class="gui-input datetime-input" data-field="updated_at.$gte" data-useless="" placeholder=">=" value="<%= searched.updated_at ? searched.updated_at.$gte : '' %>">
            </div>
            <div class="col-md-6">
                <input type="text" class="gui-input datetime-input" data-field="updated_at.$lte" data-useless="" placeholder="<=" value="<%= searched.updated_at ? searched.updated_at.$lte : '' %>">
            </div>
        </div>
        <h6 class="fw400">提现方式</h6>
        <div class="section mb15">
            <label class="field select">
                <select id="searchType" name="searchType" data-field="withdraw_type">
                    <option value="-1" <%= searched.withdraw_type == -1 ? 'selected' : '' %>>所有</option>
                    <option value="1" <%= searched.withdraw_type == 1 ? 'selected' : '' %>>支付宝</option>
                    <option value="0" <%= searched.withdraw_type == 0 ? 'selected' : '' %>>银行卡</option>
                    <option value="12" <%= searched.withdraw_type == 12 ? 'selected' : '' %>>qq钱包</option>
                    <option value="13" <%= searched.withdraw_type == 13 ? 'selected' : '' %>>微信</option>
                </select>
                <i class="arrow double"></i>
            </label>
        </div>
        <h6 class="fw400">风控状态</h6>
        <div class="section mb15">
            <label class="field select">
                <select id="searchRiskType" name="searchRiskType" data-field="risk_type">
                    <option value="0" <%= searched.risk_type == 0 ? 'selected' : '' %>>所有用户</option>
                    <option value="1" <%= searched.risk_type == 1 ? 'selected' : '' %>>风控用户</option>
                    <option value="2" <%= searched.risk_type == 2 ? 'selected' : '' %>>测试用户</option>
                    <option value="4" <%= searched.risk_type == 4 ? 'selected' : '' %>>黑名单用户</option>
                    <option value="8" <%= searched.risk_type == 8 ? 'selected' : '' %>>黑名单收款账户</option>
                    <option value="16" <%= searched.risk_type == 16 ? 'selected' : '' %>>黑名单收款姓名</option>
                    <option value="32" <%= searched.risk_type == 32 ? 'selected' : '' %>>非法用户</option>
                    <option value="64" <%= searched.risk_type == 64 ? 'selected' : '' %>>不存在累积数据</option>
                    <option value="128" <%= searched.risk_type == 128 ? 'selected' : '' %>>没有充值</option>
                    <option value="256" <%= searched.risk_type == 256 ? 'selected' : '' %>>盈利总额/累积充值>=3</option>
                    <option value="512" <%= searched.risk_type == 512 ? 'selected' : '' %>>apple pay用户</option>
                    <option value="1024" <%= searched.risk_type == 1024 ? 'selected' : '' %>>盈利总额/累积充值>=3</option>
                    <option value="2048" <%= searched.risk_type == 2048 ? 'selected' : '' %>>累计提现-累积充值-余额>=20000</option>
                    <option value="4096" <%= searched.risk_type == 4096 ? 'selected' : '' %>>累计产品玩法盈利超过20000</option>
                    <option value="8192" <%= searched.risk_type == 8192 ? 'selected' : '' %>>不存在今日数据</option>
                    <option value="16384" <%= searched.risk_type == 16384 ? 'selected' : '' %>>今日盈利数据缺失</option>
                    <option value="32768" <%= searched.risk_type == 32768 ? 'selected' : '' %>>今日盈利超过限额</option>
                    <option value="65536" <%= searched.risk_type == 65536 ? 'selected' : '' %>>当前提现金额超限</option>
                    <option value="131072" <%= searched.risk_type == 131072 ? 'selected' : '' %>>当日产品玩法盈利超过充值金额2倍</option>
                    <option value="262144" <%= searched.risk_type == 262144 ? 'selected' : '' %>>今日提现-今日玩法盈利>5000</option>
                    <option value="524288" <%= searched.risk_type == 524288 ? 'selected' : '' %>>当前提现金额超限</option>
                    <option value="1048576" <%= searched.risk_type == 1048576 ? 'selected' : '' %>>收款账号今日提现超过5w</option>
                    <option value="2097152" <%= searched.risk_type == 2097152 ? 'selected' : '' %>>当日产品玩法用户盈利超过5000</option>
                    <option value="4194304" <%= searched.risk_type == 4194304 ? 'selected' : '' %>>电销黑名单</option>
                    <option value="8388608" <%= searched.risk_type == 8388608 ? 'selected' : '' %>>运营黑名单</option>
                </select>
                <i class="arrow double"></i>
            </label>
        </div>
        <h6 class="fw400">提现状态</h6>
        <div class="section mb15">
            <label class="field select">
                <select id="searchStatus" name="searchStatus" data-field="status">
                    <option value="-1" <%= searched.status == -1 ? 'selected' : '' %>>所有</option>
                    <% _.each(WITHDRAW_STATUS, function(v, k){ %>
                    <option value="<%= k %>" <%= searched.status == k ? 'selected' : '' %>><%= v %></option>
                    <% }) %>
                </select>
                <i class="arrow double"></i>
            </label>
        </div>
        <h6 class="fw400">审核状态</h6>
        <div class="section mb15">
            <label class="field select">
                <select id="searchCheckStatus" name="searchCheckStatus" data-field="check_status">
                    <option value="-1" <%= searched.check_status == -1 ? 'selected' : '' %>>所有</option>
                    <% _.each(WITHDRAW_CHECK_STATUS, function(v, k){ %>
                    <option value="<%= k %>" <%= searched.check_status == k ? 'selected' : '' %>><%= v %></option>
                    <% }) %>
                </select>
                <i class="arrow double"></i>
            </label>
        </div>
        <hr class="short">
        <div class="row">
            <div class="col-md-6">
                <button class="btn btn-primary btn-block form-control" id="search">搜索</button>
            </div>
            <div class="col-md-6">
                <button class="btn btn-default btn-block form-control" id="export">导出</button>
            </div>
        </div>
    </div>
</aside>
<!-- End: Right Sidebar -->
